home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2003 December / The Sunday Times - The Month 2003-12.iso / mac / The Month DEC 03 / engine / modules / musts.swf / scripts / frame_1 / DoAction.as
Text File  |  2003-09-04  |  5KB  |  202 lines

  1. function loadImage(mc, node, extrapath)
  2. {
  3.    extrapath != null ? 0 : (extrapath = "");
  4.    var strDefaultPath = Tardis.ASSETS_FOLDER + "images/" + Tardis.ActiveSection.id + "/";
  5.    var strImg = node.getText();
  6.    var diffpath = node.attributes.path;
  7.    if(diffpath != null)
  8.    {
  9.       strImg = diffpath + strImg;
  10.    }
  11.    else
  12.    {
  13.       strImg = strDefaultPath + extrapath + strImg;
  14.    }
  15.    strPathPrefix != null ? 0 : (strPathPrefix = "");
  16.    mc.loadMovie(strPathPrefix + strImg);
  17. }
  18. function addLink(mc)
  19. {
  20.    Links[mc.link] = mc;
  21. }
  22. function getMCfromLink(Item)
  23. {
  24.    if(Links[Item] == null)
  25.    {
  26.       var arr = [];
  27.       while(Item != sideMenu.ItemHome)
  28.       {
  29.          arr.unshift(Item._name.split("_").pop());
  30.          Item = Item._parent._parent;
  31.       }
  32.       var str = arr.join("/");
  33.       Links[Item] = Links[str];
  34.    }
  35.    return Links[Item];
  36. }
  37. function removeLinkListener()
  38. {
  39.    Tardis.sideMenu.EB.removeListener(this);
  40. }
  41. function init()
  42. {
  43.    build();
  44. }
  45. function build()
  46. {
  47.    var strID = Tardis.ActiveSection.id;
  48.    var Colors = Tardis.Colors;
  49.    strSECTION_COLOR = Colors.getString(strID);
  50.    strSECTION_COLOR50 = Colors.getString(strID + "50");
  51.    SECTION_COLOR = Colors.getHex(strID);
  52.    SECTION_COLOR50 = Colors.getHex(strID + "50");
  53.    DEFAULT_COLOR = Colors.getHex("default");
  54.    strDEFAULT_COLOR = Colors.getString("default");
  55.    DEFAULT_COLOR50 = Colors.getHex("default50");
  56.    ndExtras = nodeData;
  57.    LENGTH_TO_TEST = ndExtras.childNodes.length;
  58.    COUNTER = 0;
  59.    countComplete = false;
  60.    IMAGE_POS_1 = 0;
  61.    var ndExtra;
  62.    var n = 0;
  63.    while(n < LENGTH_TO_TEST)
  64.    {
  65.       CONTENT_POS = 0;
  66.       ndExtra = ndExtras.childNodes[n];
  67.       var objClip = this.attachMovie("tvListingMC","mc_t_" + n,++depth);
  68.       objClip.positioned = false;
  69.       objClip.col = ndExtra.attributes.col;
  70.       objClip.link = ndExtra.attributes.link;
  71.       if(ndExtra.byName("title").getText() != null)
  72.       {
  73.          var strTitle = "<FONT COLOR=\"" + strSECTION_COLOR50 + "\">" + ndExtra.byName("title").getText() + " </FONT>";
  74.          objClip.titleFF.htmlText = strTitle;
  75.          objClip.titleFF.resize();
  76.          objClip.titleFF._y = CONTENT_POS;
  77.          CONTENT_POS += objClip.titleFF._height + 2;
  78.       }
  79.       ndImage = ndExtra.byName("image");
  80.       if(ndImage.getText() != null)
  81.       {
  82.          loadImage(objClip.mc_img_0,ndImage,IMAGE_PATH);
  83.          if(n != 0)
  84.          {
  85.             if(CONTENT_POS < IMAGE_POS_1)
  86.             {
  87.                objClip.mc_img_0._y = IMAGE_POS_1;
  88.             }
  89.             else if(IMAGE_POS_1 < CONTENT_POS)
  90.             {
  91.                mc_t_0.mc_img_0._y = CONTENT_POS;
  92.                objClip.mc_img_0._y = CONTENT_POS;
  93.             }
  94.             else
  95.             {
  96.                objClip.mc_img_0._y = CONTENT_POS;
  97.             }
  98.          }
  99.          else
  100.          {
  101.             IMAGE_POS_1 = CONTENT_POS;
  102.             objClip.mc_img_0._y = CONTENT_POS;
  103.          }
  104.          this["intervalID" + n] = setInterval(this,"checkLoad",100,objClip,n);
  105.       }
  106.       else
  107.       {
  108.          objClip.mc_img_0._height = 0;
  109.          objClip.mc_img_0._y = 0;
  110.          objClip.title2FF._height = 0;
  111.          objClip.title2FF._y = 0;
  112.          COUNTER++;
  113.       }
  114.       n++;
  115.    }
  116.    counterID = setInterval(checkCounter,100);
  117.    onComplete();
  118. }
  119. function checkCounter()
  120. {
  121.    if(COUNTER == LENGTH_TO_TEST)
  122.    {
  123.       if(!countComplete)
  124.       {
  125.          countComplete = true;
  126.          positionElements();
  127.          clearInterval(counterID);
  128.       }
  129.    }
  130. }
  131. function checkLoad(mc, num)
  132. {
  133.    if(mc.mc_img_0._height > 0)
  134.    {
  135.       if(!mc.positioned)
  136.       {
  137.          mc.positioned = true;
  138.          COUNTER++;
  139.          clearInterval(this["intervalID" + num]);
  140.       }
  141.    }
  142. }
  143. function positionElements(mc)
  144. {
  145.    positionFF.htmlText = POSI;
  146.    var ndExtra;
  147.    var n = 0;
  148.    while(n < LENGTH_TO_TEST)
  149.    {
  150.       var objClip = eval("mc_t_" + n);
  151.       objClip.btn._height = objClip._height;
  152.       objClip._x = eval("COLPOS_" + objClip.col);
  153.       objClip._y = eval("TEXTPOS_" + objClip.col);
  154.       this["TEXTPOS_" + objClip.col] += objClip._height - 3;
  155.       n++;
  156.    }
  157.    _visible = true;
  158. }
  159. function txtOver(mc)
  160. {
  161.    Tardis.sideMenu.doOver(mc.link);
  162. }
  163. function txtOut(mc)
  164. {
  165.    Tardis.sideMenu.doOut(mc.link);
  166. }
  167. function doOver(nm)
  168. {
  169.    var mc = eval("mc_t_" + nm);
  170.    mc.titleFF.textColor = SECTION_COLOR;
  171.    _parent.preview.doOver(nm);
  172. }
  173. function doOut(nm)
  174. {
  175.    var mc = eval("mc_t_" + nm);
  176.    mc.titleFF.textColor = SECTION_COLOR50;
  177.    _parent.preview.doOut(nm);
  178. }
  179. Links = {};
  180. Tardis.sideMenu.EB.addListener(this);
  181. stop();
  182. _visible = false;
  183. TEXTPOS_1 = 5;
  184. TEXTPOS_2 = 5;
  185. COLPOS_1 = 8;
  186. COLPOS_2 = 188;
  187. CONTENT_POS = 0;
  188. objpos = 0;
  189. onReady();
  190. this.onUnload = function()
  191. {
  192.    clearInterval(counterID);
  193.    var n = 0;
  194.    while(n < LENGTH_TO_TEST)
  195.    {
  196.       clearInterval(this["intervalID" + n]);
  197.       n++;
  198.    }
  199.    removeLinkListener();
  200.    this.onUnload = null;
  201. };
  202.